<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>充值</title>
	<link rel="stylesheet" href="css/amazeui.min.css" />
	<link rel="stylesheet" href="css/app.css" />
	<link rel="stylesheet" href="css/swiper-3.3.1.min.css" />
	<script src="assets/js/jquery.min.js" type="text/javascript"></script>
	<script src="js/amazeui.min.js" type="text/javascript"></script>

	<style>
		body {
			max-width: 640px;
			margin: 0 auto;
			font-size: 10px;
			background: #F2F3F8;
		}

		* {
			box-sizing: border-box;
		}

		[class*=am-u-] {
			padding: 0;
		}
	</style>
</head>

<body>
	<!--头部-->
	<header class="am-u">
		<div class="am-u-sm-12 head_nav" style="margin:0;">
			<div class="am-u-sm-2 am-vertical-align" style="text-align: center;">
				<a href="mine.html">
					<img src="img/return@2x.png" class="am-vertical-align-middle" alt="" />
				</a>
			</div>
			<div class="am-u-sm-8 head_text">
				充值
			</div>
			<div class="am-u-sm-2">

			</div>
		</div>
	</header>
	<div style="clear: both;"></div>
	<div style="background: #293A44;">
		<a href="top-up.html">
			<div style="padding:5px 10px 5px 10px;float: right;font-size: 13px;color: #fff;">
				充值明细
			</div>
		</a>
		<div style="clear: both;"></div>
		<div style="text-align: center;font-size: 16px;color: #fff;">
			账户余额（元）
		</div>
		<div id="money" style="text-align: center;font-size: 18px;padding: 20px 0 20px 0;color: #fff;">
			0
		</div>
	</div>
	<div class="ipt">
		<input type="text" placeholder="充值金额" id="money2" />
		<input type="text" placeholder="支付密码（初始化密码123456）" id="pay_pwd" />
		<div class="ipt1">
			<a href="select.html">
				<img src="img/Wallet.png" style="width:25px;padding-bottom: 5px;" alt="" />
				<span id="bank_credi" style="padding: 5px;color: #888888;">请选择银行卡</span>
				<img src="img/right1.png" width="20" style="float: right;padding-top:13px ;" alt="" />
			</a>
		</div>
	</div>
	<div style="padding: 15px;padding-bottom: 5px;">
		<button class="am-btn" id="cz_btn" style="background: #0567CD;color: #fff;width: 100%;border-radius: 5px;">充 值</button>
	</div>
	<div style="padding: 15px;padding-top: 0px;">
		<button class="am-btn" onclick="javascript:location.href='Cashwithdrawal.html';" style="background: #fff;color: #848484;width: 100%;border-radius: 5px;">提 现</button>
	</div>
	<script src="js/jquery-1.11.3.js"></script>
	<script src="js/loading.js"></script>
	<script>
		$("#money").html(sessionStorage["balance"]);
		var token1 = sessionStorage.getItem("token");
		var yyyy = sessionStorage["hh"];
		if (yyyy == 2) {
			var yyy1 = sessionStorage["bank_credit_id"];
			var yyy2 = sessionStorage["cardName"];
			var yyy3 = sessionStorage["cardAfterFour"];
			$("#bank_credi").html(yyy2 + "(**** " + yyy3 + ")");
			$("#bank_credi").attr("data1", yyy1);
			sessionStorage["hh"] = 1;
		}
		$("#cz_btn").on("click", function () {
			var money1 = $("#money2").val();
			var pay_pwd1 = $("#pay_pwd").val();
			var bank_credi1 = $("#bank_credi").attr("data1");
			// console.log(bank_credi1);
			if (!money1) {
				alert("充值金额不能为空");
				return false;
			}
			if (!pay_pwd1) {
				alert("支付密码不能为空");
				return false;
			}
			if (bank_credi1 == "请选择银行卡") {
				alert("请选择银行卡");
				return false;
			}
			$.ajax({
				type: 'POST',
				url: "http://www.rice.com/app/api/h5_access",
				contentType: "application/x-www-form-urlencoded; charset=utf-8",
				datatype: "JSON",
				data: {
					method: "Order|recharge",
					token: token1,
					money: money1,
					pay_pwd: pay_pwd1,
					bank_credit_id: bank_credi1
				},
				success: function (data) {
					var data1 = JSON.parse(data);
					if (data1.status === 1) {
						alert(data1.message);
					} else if (Number(data1.status) == 2) {
						alert(data1.message);
						window.location.href = "login.html";
					} else {
						alert(data1.message);
					}
				}
			});
		})
	</script>
</body>

</html>